{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "c7b1ef01",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-22T02:02:46.776968Z",
     "start_time": "2021-11-22T02:02:46.768932Z"
    }
   },
   "source": [
    "-------\n",
    "* 记录人：江丽婷\n",
    "* 时间：2021-11-15\n",
    "* week12\n",
    "* 主要参考文档：[Python官方文档] （https://docs.python.org/3.7/tutorial/index.html）\n",
    "\n",
    "----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d7a61987",
   "metadata": {},
   "source": [
    "# 上周回顾\n",
    "## 字典的实践（课本+课外）\n",
    "# 本周内容\n",
    "## 1.解读"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a2c7ea56",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:14:49.751459Z",
     "start_time": "2021-12-19T04:14:49.727810Z"
    }
   },
   "outputs": [],
   "source": [
    "广州南方学院 = {'status': '1',\n",
    " 'regeocode': {'roads': [{'id': '020F49F0050461206',\n",
    "    'location': '113.678,23.6284',\n",
    "    'direction': '北',\n",
    "    'name': '博学路',\n",
    "    'distance': '7.63232'},\n",
    "   {'id': '020F49F0050462229',\n",
    "    'location': '113.679,23.6245',\n",
    "    'direction': '北',\n",
    "    'name': '老虎形街',\n",
    "    'distance': '445.159'},\n",
    "   {'id': '020F49F0050462451',\n",
    "    'location': '113.677,23.6347',\n",
    "    'direction': '南',\n",
    "    'name': '中山路',\n",
    "    'distance': '708.299'}],\n",
    "  'roadinters': [{'second_name': '中山路',\n",
    "    'first_id': '020F49F0050461206',\n",
    "    'second_id': '020F49F0050462451',\n",
    "    'location': '113.676794,23.634661',\n",
    "    'distance': '708.299',\n",
    "    'first_name': '博学路',\n",
    "    'direction': '南'}],\n",
    "  'formatted_address': '广东省广州市从化区温泉镇博学路',\n",
    "  'addressComponent': {'city': '广州市',\n",
    "   'province': '广东省',\n",
    "   'adcode': '440117',\n",
    "   'district': '从化区',\n",
    "   'towncode': '440117100000',\n",
    "   'streetNumber': {'number': '24号',\n",
    "    'location': '113.677267,23.629149',\n",
    "    'direction': '西北',\n",
    "    'distance': '129.943',\n",
    "    'street': '博学路'},\n",
    "   'country': '中国',\n",
    "   'township': '温泉镇',\n",
    "   'businessAreas': [[]],\n",
    "   'building': {'name': [], 'type': []},\n",
    "   'neighborhood': {'name': [], 'type': []},\n",
    "   'citycode': '020'},\n",
    "  'aois': [],\n",
    "  'pois': [{'id': 'B0FFG4TAF2',\n",
    "    'direction': '东南',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉镇乌土村松浪队5号(近博学路)',\n",
    "    'poiweight': '0.237309',\n",
    "    'name': '广州南方公寓',\n",
    "    'location': '113.678983,23.627778',\n",
    "    'distance': '102.617',\n",
    "    'tel': '13622768437',\n",
    "    'type': '商务住宅;住宅区;住宅小区'},\n",
    "   {'id': 'B0H6FA18J5',\n",
    "    'direction': '东南',\n",
    "    'businessarea': [],\n",
    "    'address': '从莞深高速(广州南方学院南侧)',\n",
    "    'poiweight': '0.223065',\n",
    "    'name': '保利半山花园',\n",
    "    'location': '113.679358,23.627672',\n",
    "    'distance': '139.054',\n",
    "    'tel': [],\n",
    "    'type': '商务住宅;住宅区;住宅区'},\n",
    "   {'id': 'B00140TWHT',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '笃行路2',\n",
    "    'poiweight': '0.157653',\n",
    "    'name': '教工住宅1号',\n",
    "    'location': '113.678490,23.630432',\n",
    "    'distance': '222.658',\n",
    "    'tel': [],\n",
    "    'type': '商务住宅;住宅区;住宅小区'},\n",
    "   {'id': 'B0FFHRJDM9',\n",
    "    'direction': '东南',\n",
    "    'businessarea': [],\n",
    "    'address': '中大南方学院南门1号',\n",
    "    'poiweight': '0.256152',\n",
    "    'name': '中南公寓',\n",
    "    'location': '113.680349,23.627573',\n",
    "    'distance': '231.723',\n",
    "    'tel': '13711245345',\n",
    "    'type': '商务住宅;住宅区;住宅小区'},\n",
    "   {'id': 'B0HGD588HJ',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼4号',\n",
    "    'location': '113.677460,23.630490',\n",
    "    'distance': '242.901',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0FFHZH0IK',\n",
    "    'direction': '西北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路广州南方学院综合楼内',\n",
    "    'poiweight': '0.17934',\n",
    "    'name': '地下铁',\n",
    "    'location': '113.677941,23.629029',\n",
    "    'distance': '74.1376',\n",
    "    'tel': [],\n",
    "    'type': '餐饮服务;冷饮店;冷饮店'},\n",
    "   {'id': 'B0HGDU76L2',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院2号实验楼',\n",
    "    'location': '113.678211,23.630956',\n",
    "    'distance': '280.003',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0FFKP838K',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路25',\n",
    "    'poiweight': '0.191742',\n",
    "    'name': '教学楼3号(外国语学院)',\n",
    "    'location': '113.677247,23.630947',\n",
    "    'distance': '298.093',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;高等院校'},\n",
    "   {'id': 'B0HGDU8NLD',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路附近',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院1号实验楼',\n",
    "    'location': '113.678215,23.631370',\n",
    "    'distance': '326.007',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HGD58UTU',\n",
    "    'direction': '西北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路',\n",
    "    'poiweight': '0.191229',\n",
    "    'name': '广州南方学院2号教学楼',\n",
    "    'location': '113.677060,23.631346',\n",
    "    'distance': '346.352',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B00140MR9A',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号',\n",
    "    'poiweight': '0.450402',\n",
    "    'name': '广州南方学院',\n",
    "    'location': '113.679262,23.632583',\n",
    "    'distance': '471.564',\n",
    "    'tel': '020-87828988;020-61787331',\n",
    "    'type': '科教文化服务;学校;高等院校'},\n",
    "   {'id': 'B0HGDU92JD',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': [],\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼1号',\n",
    "    'location': '113.677077,23.631783',\n",
    "    'distance': '391.548',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HGD592BJ',\n",
    "    'direction': '东北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道886号广州南方学院内',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院综合楼',\n",
    "    'location': '113.680117,23.631544',\n",
    "    'distance': '392.731',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0FFKP81F0',\n",
    "    'direction': '西北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路19号附近',\n",
    "    'poiweight': '0.191742',\n",
    "    'name': '教学楼1号(文学与传媒学院)',\n",
    "    'location': '113.676866,23.631736',\n",
    "    'distance': '393.93',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
    "   {'id': 'B0FFLBEOND',\n",
    "    'direction': '东北',\n",
    "    'businessarea': [],\n",
    "    'address': '从莞深高速(广州南方学院)',\n",
    "    'poiweight': '0.190963',\n",
    "    'name': '聚贤楼10号',\n",
    "    'location': '113.681253,23.631036',\n",
    "    'distance': '418.51',\n",
    "    'tel': [],\n",
    "    'type': '商务住宅;住宅区;宿舍'},\n",
    "   {'id': 'B0FFH6K3U9',\n",
    "    'direction': '西北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉镇温泉大道882号广州南方学院H7栋1-5层',\n",
    "    'poiweight': '0.254885',\n",
    "    'name': '广州中大南方招待所',\n",
    "    'location': '113.676330,23.631332',\n",
    "    'distance': '378.102',\n",
    "    'tel': '020-61787222',\n",
    "    'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
    "   {'id': 'B0HGD58NF8',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号广州南方学院新综合楼2层',\n",
    "    'poiweight': '0.191229',\n",
    "    'name': '广州南方学院达人书院',\n",
    "    'location': '113.679041,23.632392',\n",
    "    'distance': '446.366',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
    "   {'id': 'B0FFKUVYWV',\n",
    "    'direction': '东北',\n",
    "    'businessarea': [],\n",
    "    'address': '保利桃花源',\n",
    "    'poiweight': '0.273168',\n",
    "    'name': '广州和风庭阿七度假别墅',\n",
    "    'location': '113.681736,23.630569',\n",
    "    'distance': '424.35',\n",
    "    'tel': '18681565305',\n",
    "    'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
    "   {'id': 'B0HGDU99RM',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号广州南方学院内',\n",
    "    'poiweight': '0.257947',\n",
    "    'name': '广州南方学院图书馆',\n",
    "    'location': '113.679177,23.632762',\n",
    "    'distance': '489.331',\n",
    "    'tel': '020-61787368;020-61787371',\n",
    "    'type': '科教文化服务;图书馆;图书馆'},\n",
    "   {'id': 'B0HGDU92JC',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路附近',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院4号实验楼',\n",
    "    'location': '113.679963,23.632652',\n",
    "    'distance': '498.883',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0FFL7C054',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉镇博学路882号(广州南方学院商业中心1层)',\n",
    "    'poiweight': '0.317505',\n",
    "    'name': '广州U优森特酒店',\n",
    "    'location': '113.679226,23.632528',\n",
    "    'distance': '464.819',\n",
    "    'tel': '15813395296',\n",
    "    'type': '住宿服务;住宿服务相关;住宿服务相关'},\n",
    "   {'id': 'B0FFG8CSEK',\n",
    "    'direction': '东北',\n",
    "    'businessarea': [],\n",
    "    'address': '从莞深高速(广州南方学院)',\n",
    "    'poiweight': '0.185371',\n",
    "    'name': 'L5员工宿舍',\n",
    "    'location': '113.682583,23.631487',\n",
    "    'distance': '554.129',\n",
    "    'tel': [],\n",
    "    'type': '商务住宅;住宅区;宿舍'},\n",
    "   {'id': 'B0HGD58FR2',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '广州南方学院',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼9号',\n",
    "    'location': '113.679747,23.633032',\n",
    "    'distance': '532.163',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HG5Z9JNK',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路',\n",
    "    'poiweight': '0.221553',\n",
    "    'name': '广州南方学院教学楼7号',\n",
    "    'location': '113.678600,23.633330',\n",
    "    'distance': '544.868',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HGD599JM',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号广州南方学院',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院第11教学楼',\n",
    "    'location': '113.680037,23.633173',\n",
    "    'distance': '556.036',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0GUJYPEG2',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882号广州南方学院内博学路6号之3',\n",
    "    'poiweight': '0.216026',\n",
    "    'name': '怒烤烤串(从化店)',\n",
    "    'location': '113.677160,23.632910',\n",
    "    'distance': '510.112',\n",
    "    'tel': [],\n",
    "    'type': '餐饮服务;中餐厅;特色/地方风味餐厅'},\n",
    "   {'id': 'B0HGDU6Z41',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '温泉大道882',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼6号',\n",
    "    'location': '113.678424,23.633710',\n",
    "    'distance': '586.331',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'},\n",
    "   {'id': 'B0HGD580NZ',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '博学路7号附近',\n",
    "    'poiweight': '0.285712',\n",
    "    'name': '广州南方学院惟贤门',\n",
    "    'location': '113.678437,23.633721',\n",
    "    'distance': '587.601',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;高等院校'},\n",
    "   {'id': 'B0HGDU7T1K',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '从莞深高速(广州南方学院)',\n",
    "    'poiweight': '0.191229',\n",
    "    'name': '广州南方学院教学楼10号',\n",
    "    'location': '113.680125,23.633492',\n",
    "    'distance': '592.504',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;科教文化场所;科教文化场所'},\n",
    "   {'id': 'B0HGDU76L1',\n",
    "    'direction': '北',\n",
    "    'businessarea': [],\n",
    "    'address': '中山路与博学路交叉口东南150米',\n",
    "    'poiweight': '0.221662',\n",
    "    'name': '广州南方学院教学楼5号',\n",
    "    'location': '113.678046,23.633982',\n",
    "    'distance': '616.848',\n",
    "    'tel': [],\n",
    "    'type': '科教文化服务;学校;学校'}]},\n",
    " 'info': 'OK',\n",
    " 'infocode': '10000'}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "9580ba37",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:15:32.163735Z",
     "start_time": "2021-12-19T04:15:32.154186Z"
    }
   },
   "outputs": [],
   "source": [
    "# 广州南方学院"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ebac686e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:15:34.046410Z",
     "start_time": "2021-12-19T04:15:34.040430Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys(['status', 'regeocode', 'info', 'infocode'])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 1.先从keys和values来观察字典\n",
    "#  keys：有多少关键字属性   values：可以观察具体的属性内容\n",
    "广州南方学院.keys()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "72a7f857",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:15:36.574289Z",
     "start_time": "2021-12-19T04:15:36.562251Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'1'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院['status']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "7e1c2090",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:15:38.851825Z",
     "start_time": "2021-12-19T04:15:38.845512Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'OK'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院['info']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "40a0b14e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:15:52.157941Z",
     "start_time": "2021-12-19T04:15:52.138246Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'10000'"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院['infocode']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "9e244e30",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:16:04.370434Z",
     "start_time": "2021-12-19T04:16:04.353457Z"
    }
   },
   "outputs": [],
   "source": [
    "广州南方学院['regeocode']  #找到核心数据  \n",
    "广州南方学院_regeocode = 广州南方学院['regeocode']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "74487978",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:16:08.335883Z",
     "start_time": "2021-12-19T04:16:08.315372Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict_keys(['roads', 'roadinters', 'formatted_address', 'addressComponent', 'aois', 'pois'])"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院_regeocode.keys()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "fd4ceb2e",
   "metadata": {},
   "source": [
    "> 1.aois (例如抖音上你搜索过的关键信息)\n",
    "> 2.pois （关键信息所连接的关联信息）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "0a445be9",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:16:16.763045Z",
     "start_time": "2021-12-19T04:16:16.745290Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'id': '020F49F0050461206',\n",
       "  'location': '113.678,23.6284',\n",
       "  'direction': '北',\n",
       "  'name': '博学路',\n",
       "  'distance': '7.63232'},\n",
       " {'id': '020F49F0050462229',\n",
       "  'location': '113.679,23.6245',\n",
       "  'direction': '北',\n",
       "  'name': '老虎形街',\n",
       "  'distance': '445.159'},\n",
       " {'id': '020F49F0050462451',\n",
       "  'location': '113.677,23.6347',\n",
       "  'direction': '南',\n",
       "  'name': '中山路',\n",
       "  'distance': '708.299'}]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院_regeocode['roads']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "820e3648",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:16:20.981184Z",
     "start_time": "2021-12-19T04:16:20.970204Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[{'second_name': '中山路',\n",
       "  'first_id': '020F49F0050461206',\n",
       "  'second_id': '020F49F0050462451',\n",
       "  'location': '113.676794,23.634661',\n",
       "  'distance': '708.299',\n",
       "  'first_name': '博学路',\n",
       "  'direction': '南'}]"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院_regeocode['roadinters']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "3f67c0e5",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:16:26.665989Z",
     "start_time": "2021-12-19T04:16:26.648877Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'广东省广州市从化区温泉镇博学路'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院_regeocode['formatted_address']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "8f927c42",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:16:28.619091Z",
     "start_time": "2021-12-19T04:16:28.610446Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'city': '广州市',\n",
       " 'province': '广东省',\n",
       " 'adcode': '440117',\n",
       " 'district': '从化区',\n",
       " 'towncode': '440117100000',\n",
       " 'streetNumber': {'number': '24号',\n",
       "  'location': '113.677267,23.629149',\n",
       "  'direction': '西北',\n",
       "  'distance': '129.943',\n",
       "  'street': '博学路'},\n",
       " 'country': '中国',\n",
       " 'township': '温泉镇',\n",
       " 'businessAreas': [[]],\n",
       " 'building': {'name': [], 'type': []},\n",
       " 'neighborhood': {'name': [], 'type': []},\n",
       " 'citycode': '020'}"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院_regeocode['addressComponent']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "26722c5a",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:16:32.259189Z",
     "start_time": "2021-12-19T04:16:32.240376Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院_regeocode['aois']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "c28c5086",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:19:00.797960Z",
     "start_time": "2021-12-19T04:19:00.792953Z"
    }
   },
   "outputs": [],
   "source": [
    "广州南方学院_regeocode_pois = 广州南方学院_regeocode['pois']\n",
    "# 广州南方学院_regeocode_pois"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "2b19a986",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:19:02.680019Z",
     "start_time": "2021-12-19T04:19:02.674034Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "30"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 操作列表\n",
    "# 1.查看列表的长度 len()\n",
    "# 2.查看其中一个数据，数据的形式和属性\n",
    "\n",
    "len(广州南方学院_regeocode['pois'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "510b5641",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:19:04.024220Z",
     "start_time": "2021-12-19T04:19:04.017203Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'id': 'B0FFG4TAF2',\n",
       " 'direction': '东南',\n",
       " 'businessarea': [],\n",
       " 'address': '温泉镇乌土村松浪队5号(近博学路)',\n",
       " 'poiweight': '0.237309',\n",
       " 'name': '广州南方公寓',\n",
       " 'location': '113.678983,23.627778',\n",
       " 'distance': '102.617',\n",
       " 'tel': '13622768437',\n",
       " 'type': '商务住宅;住宅区;住宅小区'}"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "广州南方学院_regeocode_pois[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "165e0f6f",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:19:58.290781Z",
     "start_time": "2021-12-19T04:19:58.274496Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['B0FFG4TAF2',\n",
       " 'B0H6FA18J5',\n",
       " 'B00140TWHT',\n",
       " 'B0FFHRJDM9',\n",
       " 'B0HGD588HJ',\n",
       " 'B0FFHZH0IK',\n",
       " 'B0HGDU76L2',\n",
       " 'B0FFKP838K',\n",
       " 'B0HGDU8NLD',\n",
       " 'B0HGD58UTU',\n",
       " 'B00140MR9A',\n",
       " 'B0HGDU92JD',\n",
       " 'B0HGD592BJ',\n",
       " 'B0FFKP81F0',\n",
       " 'B0FFLBEOND',\n",
       " 'B0FFH6K3U9',\n",
       " 'B0HGD58NF8',\n",
       " 'B0FFKUVYWV',\n",
       " 'B0HGDU99RM',\n",
       " 'B0HGDU92JC',\n",
       " 'B0FFL7C054',\n",
       " 'B0FFG8CSEK',\n",
       " 'B0HGD58FR2',\n",
       " 'B0HG5Z9JNK',\n",
       " 'B0HGD599JM',\n",
       " 'B0GUJYPEG2',\n",
       " 'B0HGDU6Z41',\n",
       " 'B0HGD580NZ',\n",
       " 'B0HGDU7T1K',\n",
       " 'B0HGDU76L1']"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 2. 请找出所有的 pois 中的字典元素 的 id，存到一个id列表中\n",
    "id_list = []\n",
    "for i in 广州南方学院_regeocode_pois:\n",
    "#     print(i['id'])\n",
    "    id_list.append(i['id'])\n",
    "id_list   "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "3e64413e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:19:07.649069Z",
     "start_time": "2021-12-19T04:19:07.633681Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "广州南方公寓\n",
      "保利半山花园\n",
      "教工住宅1号\n",
      "中南公寓\n",
      "广州南方学院教学楼4号\n",
      "地下铁\n",
      "广州南方学院2号实验楼\n",
      "教学楼3号(外国语学院)\n",
      "广州南方学院1号实验楼\n",
      "广州南方学院2号教学楼\n",
      "广州南方学院\n",
      "广州南方学院教学楼1号\n",
      "广州南方学院综合楼\n",
      "教学楼1号(文学与传媒学院)\n",
      "聚贤楼10号\n",
      "广州中大南方招待所\n",
      "广州南方学院达人书院\n",
      "广州和风庭阿七度假别墅\n",
      "广州南方学院图书馆\n",
      "广州南方学院4号实验楼\n",
      "广州U优森特酒店\n",
      "L5员工宿舍\n",
      "广州南方学院教学楼9号\n",
      "广州南方学院教学楼7号\n",
      "广州南方学院第11教学楼\n",
      "怒烤烤串(从化店)\n",
      "广州南方学院教学楼6号\n",
      "广州南方学院惟贤门\n",
      "广州南方学院教学楼10号\n",
      "广州南方学院教学楼5号\n"
     ]
    }
   ],
   "source": [
    "# 3. 请找出所有的pois中的字典元素的 name\n",
    "for i in 广州南方学院_regeocode_pois:\n",
    "    print(i['name'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "5e49daf3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:20:01.617289Z",
     "start_time": "2021-12-19T04:20:01.610272Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "广州南方学院教学楼4号\n",
      "教学楼3号(外国语学院)\n",
      "广州南方学院2号教学楼\n",
      "广州南方学院教学楼1号\n",
      "教学楼1号(文学与传媒学院)\n",
      "广州南方学院教学楼9号\n",
      "广州南方学院教学楼7号\n",
      "广州南方学院第11教学楼\n",
      "广州南方学院教学楼6号\n",
      "广州南方学院教学楼10号\n",
      "广州南方学院教学楼5号\n"
     ]
    }
   ],
   "source": [
    "# 4.请找出 所有的 教学楼 在 上题中多一步筛选 if+in（成员查询）\n",
    "for i in 广州南方学院_regeocode_pois:\n",
    "    if '教学楼' in i['name']:\n",
    "        print(i['name'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "bf02e094",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:21:04.994983Z",
     "start_time": "2021-12-19T04:21:04.988003Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "广州南方学院2号教学楼\n",
      "教学楼1号(文学与传媒学院)\n"
     ]
    }
   ],
   "source": [
    "# 5. 请找出 朝向 为 北 的教学楼\n",
    "for i in 广州南方学院_regeocode_pois:\n",
    "    if '教学楼' in i['name']:\n",
    "        if i['direction'] == '西北':\n",
    "            print(i['name'])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "59d8f93b",
   "metadata": {},
   "source": [
    "# 3.集合\n",
    "> 1.[集合]( https://docs.python.org/3/tutorial/datastructures.html#sets )的概念\n",
    "> 2.集合的形式：{value1,value2,value3,...}\n",
    "> 3.集合的性质：\n",
    ">> 1.唯一性（去除重复项:一般可以用来查看列表的成员属性）\n",
    ">> 2.可变\n",
    ">> 3.无序\n",
    "\n",
    "> 4.集合可以用 in 进行成员查询"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "3b0a4537",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-22T03:03:32.356794Z",
     "start_time": "2021-11-22T03:03:32.350496Z"
    }
   },
   "outputs": [],
   "source": [
    "basket = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "e8849ab5",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-22T03:06:11.613489Z",
     "start_time": "2021-11-22T03:06:11.602945Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'set'> \n",
      " {'orange', 'pear', 'apple', 'banana'}\n"
     ]
    }
   ],
   "source": [
    "print(type(basket),'\\n',basket)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ab81414b",
   "metadata": {},
   "source": [
    "## 1.集合的运算\n",
    "> 1.交集运算 intersection()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "2ce9b0f3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:29:51.617891Z",
     "start_time": "2021-12-19T04:29:51.601147Z"
    }
   },
   "outputs": [],
   "source": [
    "list_1 = [1,2,5,6,7,2,3,2,4,4]\n",
    "set_1 = set(list_1)   # list to set的方法 set(list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "f587b5e0",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:29:52.119404Z",
     "start_time": "2021-12-19T04:29:52.099458Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1, 2, 3, 4, 5, 6, 7}"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "6922a92f",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:29:52.569558Z",
     "start_time": "2021-12-19T04:29:52.559551Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0, 1, 3, 4, 7, 8, 66}"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_2 = set([1,3,4,0,8,66,7])\n",
    "set_2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "c2c4650c",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:29:52.801561Z",
     "start_time": "2021-12-19T04:29:52.788677Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function intersection:\n",
      "\n",
      "intersection(...) method of builtins.set instance\n",
      "    Return the intersection of two sets as a new set.\n",
      "    \n",
      "    (i.e. all elements that are in both sets.)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(set_1.intersection)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "aaf15e74",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:29:53.003732Z",
     "start_time": "2021-12-19T04:29:52.992761Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1, 3, 4, 7}"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_1.intersection(set_2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "69e3a477",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:29:53.313478Z",
     "start_time": "2021-12-19T04:29:53.293663Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1, 3, 4, 7}"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_intersection = set_1.intersection(set_2)\n",
    "new_intersection"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f46d7d4e",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-22T03:14:40.588368Z",
     "start_time": "2021-11-22T03:14:40.569610Z"
    }
   },
   "source": [
    "> 2.并集运算 union()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "3642c35c",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:29:53.735950Z",
     "start_time": "2021-12-19T04:29:53.729644Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function union:\n",
      "\n",
      "union(...) method of builtins.set instance\n",
      "    Return the union of sets as a new set.\n",
      "    \n",
      "    (i.e. all elements that are in either set.)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(set_1.union)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "43bc584d",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:29:53.986992Z",
     "start_time": "2021-12-19T04:29:53.977788Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1, 2, 3, 4, 5, 6, 7}"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "621ebdb2",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:29:54.331565Z",
     "start_time": "2021-12-19T04:29:54.323570Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0, 1, 3, 4, 7, 8, 66}"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "id": "d349d925",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:29:54.600203Z",
     "start_time": "2021-12-19T04:29:54.591229Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0, 1, 2, 3, 4, 5, 6, 7, 8, 66}"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_1.union(set_2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c440ae85",
   "metadata": {},
   "source": [
    ">3. 差集运算 : 注意：差集运算考虑先后顺序"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "fa213dd1",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:29:55.649927Z",
     "start_time": "2021-12-19T04:29:55.640014Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1, 2, 3, 4, 5, 6, 7}"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "22475630",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:29:56.568581Z",
     "start_time": "2021-12-19T04:29:56.560601Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0, 1, 3, 4, 7, 8, 66}"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "24b49ea9",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:29:57.208391Z",
     "start_time": "2021-12-19T04:29:57.202412Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{2, 5, 6}"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_1-set_2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "fd45d795",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:30:14.152163Z",
     "start_time": "2021-12-19T04:30:14.142084Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{2, 5, 6}"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_1.difference(set_2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "id": "6334a268",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:30:34.472521Z",
     "start_time": "2021-12-19T04:30:34.454569Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0, 8, 66}"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_2.difference(set_1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "4ae2a56d",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:30:42.790975Z",
     "start_time": "2021-12-19T04:30:42.773052Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0, 2, 5, 6, 8, 66}"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_1.symmetric_difference(set_2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "79b2bd03",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:30:43.481540Z",
     "start_time": "2021-12-19T04:30:43.475711Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{0, 2, 5, 6, 8, 66}"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_2.symmetric_difference(set_1)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "adde441c",
   "metadata": {},
   "source": [
    "## 集合的一般方法"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "fd53ab71",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:34:31.363861Z",
     "start_time": "2021-12-19T04:34:31.357237Z"
    }
   },
   "outputs": [],
   "source": [
    "set_3=set([1,3,4,0,8,66,7])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8ed590e4",
   "metadata": {},
   "source": [
    "> 1.增加add()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "id": "204b5ed1",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:34:37.229533Z",
     "start_time": "2021-12-19T04:34:37.225517Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function add:\n",
      "\n",
      "add(...) method of builtins.set instance\n",
      "    Add an element to a set.\n",
      "    \n",
      "    This has no effect if the element is already present.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(set_3.add)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "id": "ecb67d57",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:35:03.648192Z",
     "start_time": "2021-12-19T04:35:03.633210Z"
    }
   },
   "outputs": [],
   "source": [
    "set_3.add(9)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "id": "ea969c5c",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:35:09.138589Z",
     "start_time": "2021-12-19T04:35:09.129574Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{0, 1, 66, 3, 4, 7, 8, 9}\n"
     ]
    }
   ],
   "source": [
    "print(set_3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7ed161e3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-11-22T03:44:11.589320Z",
     "start_time": "2021-11-22T03:44:11.577509Z"
    }
   },
   "source": [
    "> 2.删除\n",
    ">> 1.pop():Remove \n",
    ">> 2.remove()好像很多余？\n",
    ">> 3.discard(member)不会报KeyError错误"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "b0b59ec6",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:35:24.309348Z",
     "start_time": "2021-12-19T04:35:24.304363Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function pop:\n",
      "\n",
      "pop(...) method of builtins.set instance\n",
      "    Remove and return an arbitrary set element.\n",
      "    Raises KeyError if the set is empty.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(set_3.pop)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "id": "a7301f24",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:35:25.101367Z",
     "start_time": "2021-12-19T04:35:25.096382Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_3.pop()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "id": "3583a004",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:35:44.925056Z",
     "start_time": "2021-12-19T04:35:44.918131Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{1, 66, 3, 4, 7, 8, 9}\n"
     ]
    }
   ],
   "source": [
    "print(set_3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 60,
   "id": "5a8c4ba3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:35:55.519487Z",
     "start_time": "2021-12-19T04:35:55.507483Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function remove:\n",
      "\n",
      "remove(...) method of builtins.set instance\n",
      "    Remove an element from a set; it must be a member.\n",
      "    \n",
      "    If the element is not a member, raise a KeyError.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(set_3.remove)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "31e9f941",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:36:01.302218Z",
     "start_time": "2021-12-19T04:36:01.299192Z"
    }
   },
   "outputs": [],
   "source": [
    "if 66 in set_3:\n",
    "    set_3.remove(66)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "a04650df",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:36:09.029218Z",
     "start_time": "2021-12-19T04:36:09.020322Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1, 3, 4, 7, 8, 9}"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "47732a9b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:36:30.731415Z",
     "start_time": "2021-12-19T04:36:30.720412Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Help on built-in function discard:\n",
      "\n",
      "discard(...) method of builtins.set instance\n",
      "    Remove an element from a set if it is a member.\n",
      "    \n",
      "    If the element is not a member, do nothing.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "help(set_3.discard)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "63ed63b7",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:36:47.529435Z",
     "start_time": "2021-12-19T04:36:47.518408Z"
    }
   },
   "outputs": [],
   "source": [
    "set_3.discard(9)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "717f9c1a",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:36:54.070916Z",
     "start_time": "2021-12-19T04:36:54.054913Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{1, 3, 4, 7, 8}"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "set_3"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "46dd68af",
   "metadata": {},
   "source": [
    "# 5.集合实践（课本）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "4aa3622d",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2021-12-19T04:37:15.261136Z",
     "start_time": "2021-12-19T04:37:10.761490Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Provide a word to search for vowels:hello\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "{'e', 'o'}"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vowels = set('aeiou')\n",
    "word = input(\"Provide a word to search for vowels:\")\n",
    "found = vowels.intersection(set(word))\n",
    "found"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c58b09a4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1f9334a4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a7ee4afb",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
